package com.nulldev.util.encoding.compression.dictonary;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

import com.nulldev.util.math.MathUtil;
import com.nulldev.util.other.RandomUtils.nSecureRandom;

public class Dictonary {

	public static byte[] generateEfficentDictonary(final int alloc) {
		int currentSize = 0;
		final ByteArrayOutputStream baos = new ByteArrayOutputStream(alloc);
		final nSecureRandom nsr = new nSecureRandom();
		while (currentSize < alloc) {
			final int toWrite = MathUtil.randInt(160, 480);
			byte[] toWrite0 = new byte[toWrite];
			nsr.nextBytes(toWrite0);
			try {
				baos.write(toWrite0);
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		final byte[] d = baos.toByteArray();
		try {
			baos.close();
		} catch (IOException e) {
		}
		return d;
	}
}
